<?php
load_ctl("admin_Common");
class Admin_MessageController extends Admin_CommonController {
	function init(){
		parent::init();
		load_model('Message');
		$this->mes = new Message();
	}
	public function indexAction(){
		$this->view->title = "留言信息";
		$this->view->mes_list = $this->mes->get_message_list();
		$page = isset($_GET["p"]) ? intval($_GET["p"]) : 1;
	    $page < 1 && $page = 1;
		$page_size = 10;
		
		$paginator = Zend_Paginator::factory($this->view->mes_list); 
		$paginator->setCurrentPageNumber($page);
		$paginator->setItemCountPerPage($page_size); 
		$this->view->paginator = $paginator;
		$this->view->mainphp = 'views/scripts/admin/index/message.phtml';
		echo $this->view->render("index.phtml");
	}
	
	public function replyAction(){
		if(isset($_GET["id"]) && is_numeric($_GET["id"])){
			$id = intval($_GET["id"]);
		}else{
			$this->_redirect('/');
		}
		$this->view->mes_info = $this->mes->get_message_info($id);
		$this->view->mainphp = 'views/scripts/admin/index/mesreply.phtml';
		echo $this->view->render("index.phtml");
	}
	
	public function domesAction(){
		
		if($this->_request->isPost()){
			$filter = new Zend_Filter_StripTags();
			$id = $filter->filter($this->_request->getPost('id'));
			$last_content = $filter->filter($this->_request->getPost('mes_content'))."<br/><br/><font color=red>ph?回复：".
			$filter->filter($this->_request->getPost('reply_content'))."</font>";
			$data = array(
				'mes_content'=>$last_content,
			);
			$this->mes->update_mes($id,$data);
			php_alert("回复留言成功",$this->view->adminurl."/message");
		}else{
			$this->_redirect('/');
		}
	}
	
}
?>